From 32c4677b93764bfe5f71faba207e1525020a2082 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Mon, 30 Jun 2025 16:19:34 -0400 Subject: [PATCH] [PATCH] Add mute/block management on the safety page This allows you to manage your muted/blocked users without having to navigate to their profile first. CCBUG: 506374 Gbp-Pq: Name upstream_4f09a6e8_Add-mute-block-management-on-the-safety-page.patch --- src/account/socialgraphmodel.cpp | 40 ++++++++++++++++++++++++++++++ src/account/socialgraphmodel.h | 6 +++++ src/content/ui/SocialGraphPage.qml | 12 +++++++++ 3 files changed, 58 insertions(+) diff --git a/src/account/socialgraphmodel.cpp b/src/account/socialgraphmodel.cpp index 47db3cf..a49f10b 100644 --- a/src/account/socialgraphmodel.cpp +++ b/src/account/socialgraphmodel.cpp @@ -251,6 +251,16 @@ bool SocialGraphModel::isList() const return m_followListName == QStringLiteral("list"); } +bool SocialGraphModel::isBlockList() const +{ + return m_followListName == QStringLiteral("blocks"); +} + +bool SocialGraphModel::isMuteList() const +{ + return m_followListName == QStringLiteral("mutes"); +} + void SocialGraphModel::actionAllow(const QModelIndex &index) { auto account = AccountManager::instance().selectedAccount(); @@ -371,6 +381,36 @@ void SocialGraphModel::actionAddToList(const QString &accountId) }); } +void SocialGraphModel::actionUnblock(const QModelIndex &index) +{ + auto account = AccountManager::instance().selectedAccount(); + + if (!checkIndex(index, QAbstractItemModel::CheckIndexOption::IndexIsValid)) + return; + + auto requestIdentity = m_accounts[index.row()].get(); + account->unblockAccount(requestIdentity); + + beginRemoveRows({}, index.row(), index.row()); + m_accounts.removeAt(index.row()); + endRemoveRows(); +} + +void SocialGraphModel::actionUnmute(const QModelIndex &index) +{ + auto account = AccountManager::instance().selectedAccount(); + + if (!checkIndex(index, QAbstractItemModel::CheckIndexOption::IndexIsValid)) + return; + + auto requestIdentity = m_accounts[index.row()].get(); + account->unmuteAccount(requestIdentity); + + beginRemoveRows({}, index.row(), index.row()); + m_accounts.removeAt(index.row()); + endRemoveRows(); +} + bool SocialGraphModel::canFetchMore(const QModelIndex &parent) const { Q_UNUSED(parent); diff --git a/src/account/socialgraphmodel.h b/src/account/socialgraphmodel.h index 4bf6fce..9180419 100644 --- a/src/account/socialgraphmodel.h +++ b/src/account/socialgraphmodel.h @@ -23,6 +23,8 @@ class SocialGraphModel : public QAbstractListModel Q_PROPERTY(bool isFollowing READ isFollowing CONSTANT) Q_PROPERTY(bool isFollower READ isFollower CONSTANT) Q_PROPERTY(bool isList READ isList CONSTANT) + Q_PROPERTY(bool isMuteList READ isMuteList CONSTANT) + Q_PROPERTY(bool isBlockList READ isBlockList CONSTANT) /** * @brief The account id of the account we want to display @@ -56,6 +58,8 @@ public: [[nodiscard]] bool isFollowing() const; [[nodiscard]] bool isFollower() const; [[nodiscard]] bool isList() const; + [[nodiscard]] bool isMuteList() const; + [[nodiscard]] bool isBlockList() const; [[nodiscard]] QString statusId() const; void setStatusId(const QString &statusId); [[nodiscard]] int count() const; @@ -70,6 +74,8 @@ public Q_SLOTS: void actionRemoveFollower(const QModelIndex &index); void actionRemoveFromList(const QModelIndex &index); void actionAddToList(const QString &accountId); + void actionUnblock(const QModelIndex &index); + void actionUnmute(const QModelIndex &index); Q_SIGNALS: void loadingChanged(); diff --git a/src/content/ui/SocialGraphPage.qml b/src/content/ui/SocialGraphPage.qml index 2bc6db9..9133cb3 100644 --- a/src/content/ui/SocialGraphPage.qml +++ b/src/content/ui/SocialGraphPage.qml @@ -94,6 +94,18 @@ Kirigami.ScrollablePage { onClicked: model.actionRemoveFromList(model.index(delegate.index, 0)) visible: model.isList && model.accountId === AccountManager.selectedAccount.identity.id } + + QQC2.Button { + text: i18nc("@action:button Unblock this user", "Unblock") + onClicked: model.actionUnblock(model.index(delegate.index, 0)) + visible: model.isBlockList + } + + QQC2.Button { + text: i18nc("@action:button Unmute this user", "Unmute") + onClicked: model.actionUnmute(model.index(delegate.index, 0)) + visible: model.isMuteList + } } QQC2.ProgressBar { -- 2.30.2